package com.cskaoyan.controller.wx;

import com.cskaoyan.bean.BaseRespVo;
import com.cskaoyan.bean.wxindex.WXIndexVo;
import com.cskaoyan.service.UserService;
import com.cskaoyan.service.wx.UserIndexService;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * \* Description:
 * \
 */
@RestController
@RequestMapping("wx")
public class WXUserIndexController {

    @Autowired
    UserIndexService userIndexService;

    @RequestMapping("user/index")
    public BaseRespVo index() {
//查询四条语句获得数量
        String primaryPrincipal = (String) SecurityUtils.getSubject().getPrincipals().getPrimaryPrincipal();
        int id = userIndexService.getIdByprimaryPrincipal(primaryPrincipal);
        int unrecv = userIndexService.unrecv(id);
        int uncomment = userIndexService.uncomment(id);
        int unpaid = userIndexService.unpaid(id);
        int unship = userIndexService.unship(id);
        WXIndexVo wxIndexVo = new WXIndexVo();
        WXIndexVo.OrderBean orderBean = new WXIndexVo.OrderBean();
        orderBean.setUncomment(uncomment);
        orderBean.setUnpaid(unpaid);
        orderBean.setUnrecv(unrecv);
        orderBean.setUnship(unship);
        wxIndexVo.setOrder(orderBean);
        return BaseRespVo.ok(wxIndexVo);
    }



}
